package com.itheima.homework10;

public class FindJava {
    public static void main(String[] args) {
        String s = "Java语言是面向对象的，Java语言是健壮的，Java语言是安全的，Java是高性能的，Java语言是跨平台的";
        fountCount(s);
        String[] names = {"张三","李四","王五","柳岩","杨幂","柳飘飘","柳青"};
        findcon(names);
    }
    public static void fountCount(String str){
        int count =0;
        while (str.contains("Java")){
            int index = str.indexOf("Java");
            str = str.substring(index + "Java".length());
            count++;
        }
        System.out.println(count);
    }
    /*
    //筛选出以下人名中以柳姓开头的人有几个
        String[] names = {"张三","李四","王五","柳岩","杨幂","柳飘飘"};

     */
    public static void findcon(String[] str){
        int count = 0;
        for (int i = 0; i < str.length; i++) {
            boolean flag = str[i].startsWith("柳");
            if(flag){
                count++;
            }
        }
        System.out.println(count);
    }
}
